<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      lang="zh-cn">

<head>
    <meta content="云之讯,云通讯,云通讯平台" name="keywords"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>
    <title>短信平台运营系统 </title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <link th:href="@{/resources/css/bootstrap.min14ed.css?v=3.3.6}" rel="stylesheet">
    <link th:href="@{/resources/css/font-awesome.min93e3.css?v=4.4.0}" rel="stylesheet">
    <!-- jqgrid-->
    <link th:href="@{/resources/css/animate.min.css}" rel="stylesheet">
    <link th:href="@{/resources/css/plugins/sweetalert/sweetalert.css}" rel="stylesheet">
    <link th:href="@{/resources/css/style.min862f.css?v=4.1.0}" rel="stylesheet">
    <style>
        .laydate_btn{
            display:none;
        }
    </style>
</head>
<body><div th:replace="stat :: statCode"></div>
<div style="margin-top: 20px;">
    <div class="wrapper wrapper-content">
        <div class="row">
            <div class="col-sm-12">
                <input type="hidden" id="paytype">
                <input type="hidden" id="clientId">
                <form class="form-horizontal">
                    <div class="form-group">
                        <label class="col-xs-3 control-label"><span class="red">*</span>计费规则：</label>
                        <div class="col-xs-8">
                            <select class="form-control js-key" id="chargeRule"  data-key="chargeRule">
                                <option value="0" th:selected="${chargeRule} eq 0">提交量</option>
                                <option value="1" th:selected="${chargeRule} eq 1">成功量</option>
                                <option value="2" th:selected="${chargeRule} eq 2">明确成功量</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group" th:if="${chargeRule} != 0">
                        <div  class="js-return">
                            <label class="col-xs-3 control-label " ><span class="red">*</span>是否自动返还：</label>
                            <div class="col-xs-8 ">
                                <select class="form-control" id="autoReturn">
                                    <option value="0">不自动返还</option>
                                    <option value="1" disabled>自动返还</option>
                                </select>
                            </div>
                        </div>
                        <div th:if="${chargeRule} == 0" style="display: none;" class="js-return">
                            <label class="col-xs-3 control-label"><span class="red">*</span>是否自动返还：</label>
                            <div class="col-xs-8">
                                <select class="form-control" id="autoReturn">
                                    <option value="0">不自动返还</option>
                                    <option value="1" disabled>自动返还</option>
                                </select>
                            </div>

                        </div>
                    </div>
                    <div class="form-group" th:if="${chargeRule} == 0">
                        <div  style="display: none;" class="js-return">
                            <label class="col-xs-3 control-label"><span class="red">*</span>是否自动返还：</label>
                            <div class="col-xs-8">
                                <select class="form-control" id="autoReturn">
                                    <option value="0">不自动返还</option>
                                    <option value="1" disabled>自动返还</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-3 control-label"><span class="red">*</span>生效时间：</label>
                        <div class="col-xs-8">
                            <input type="text" class="form-control" id="time_day" th:value="${effectDate}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-3 control-label"></label>
                        <div class="col-xs-8">
                            <a href="javascript:;" class="btn btn-success js-confirm">确认</a>
                            <a href="javascript:;" class="btn btn-default js-cancel">取消</a>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<script th:src="@{/resources/js/hex_ha_ha_ha_ha_ha.js}"></script>
<script th:src="@{/resources/js/jquery.min.js?v=2.1.4}"></script>
<script th:src="@{/resources/js/bootstrap.min.js?v=3.3.6}"></script>
<script th:src="@{/resources/js/plugins/peity/jquery.peity.min.js}"></script>
<script th:src="@{/resources/js/content.min.js?v=1.0.0}"></script>
<script th:src="@{/resources/js/date_format.min.js?v=1.0.0}"></script>
<script th:src="@{/resources/js/jquery.form.js?v=1.0.0}"></script>
<script th:src="@{/resources/js/plugins/layer/laydate/laydate.js}"></script>
<script th:src="@{/resources/js/plugins/sweetalert/sweetalert.min.js}"></script>
<script th:src="@{/resources/js/plugins/validate/jquery.validate.min.js}"></script>
<script th:src="@{/resources/js/common.js?v=1.0.0}"></script>
<script th:src="@{/resources/js/layer/layer.js}"></script>
<script th:inline="javascript">
    /*<![CDATA[*/


    $(function () {
        $("#clientId").val(getQueryString("clientId"))
        $("#paytype").val(getQueryString("paytype"))


        var end = {
            elem: "#time_day",
            format: "YYYY-MM-DD",
            min: getNextDay("yyyy-MM-dd")
//            max: laydate.now(),


        };
        laydate(end);

        //计费规则
        $("#chargeRule").change(function(){
            var val = $("#chargeRule").val();
            var paytype = $("#paytype").val();
            if(val != 0 && paytype == 0){
                $(".js-return").show();
            } else{
                $(".js-return").hide();
            }

        })

        $(".js-cancel").click(function(){
            parent.layer.closeAll();
        })

        $(".js-confirm").click(function(){
            var clientid = $("#clientId").val();
            var chargeRule = $("#chargeRule").val();
            var extValue = $("#autoReturn").val();
            var effectDate = $("#time_day").val();

            if(effectDate == "" || effectDate === null || effectDate === undefined){
                layer.msg("请选择生效时间",{icon:2})
                return;
            }
            var params = {
                clientid:clientid,
                chargeRule:chargeRule,
                extValue:extValue,
                effectDate:effectDate + " 00:00:00"
            }
            $.ajax({
                url :'/accountInfo/client/edit/chargerule',
                type : "POST",
                dataType : 'json',
                data: JSON.stringify(params),
                contentType: "application/json",
                success : function(res){
                    if(res.code != 0){
                        layer.msg(res.msg,{icon:2});
                        return;
                    }
                    var _p = parent;
                    parent.layer.msg(res.msg, {icon: 1,time: 1500},function(){
                        _p.location.reload();
                    });
                }
            })
        })
    });



    /*]]>*/
</script>
</body>
</html>